



project , uses("constituency_elections.dta")


	
	
	


	***	Pre-treatment trends
	foreach v in  spending_total_adj   inc_vote_pct  candidates effective_candidates {   
		
		use "constituency_elections.dta", clear //open data

		reghdfe  `v'  F0.spending_limit_predicted_adj F1.spending_limit_predicted_adj F2.spending_limit_predicted_adj  L1.spending_limit_predicted_adj L2.spending_limit_predicted_adj    countyXelectors , a(  const_id date  i.date#c.electors     ) cluster(const_id) 
	
		
		gen est = .
		gen upper95 = .
		gen lower95 = .
		gen upper90 = .
		gen lower90 = .
		gen t = . 
		
		qui forval i = 0/2 {
			replace t = -`i' if _n==`i'+1
			replace est = _b[F`i'.spending_limit_predicted_adj] if _n==`i' +1
			replace upper95 = _b[F`i'.spending_limit_predicted_adj] + 1.96*_se[F`i'.spending_limit_predicted_adj] if _n==`i'+1
			replace lower95 = _b[F`i'.spending_limit_predicted_adj] - 1.96*_se[F`i'.spending_limit_predicted_adj] if _n==`i'+1	
		
			replace upper90 = _b[F`i'.spending_limit_predicted_adj] + 1.64*_se[F`i'.spending_limit_predicted_adj] if _n==`i'+1
			replace lower90 = _b[F`i'.spending_limit_predicted_adj] - 1.64*_se[F`i'.spending_limit_predicted_adj] if _n==`i'+1	
		}
		
		
		qui forval i = 1/2 {
			replace t = `i' if _n==`i'+10
			replace est = _b[L`i'.spending_limit_predicted_adj] if _n==`i' +10
			replace upper95 = _b[L`i'.spending_limit_predicted_adj] + 1.96*_se[L`i'.spending_limit_predicted_adj] if _n==`i'+10
			replace lower95 = _b[L`i'.spending_limit_predicted_adj] - 1.96*_se[L`i'.spending_limit_predicted_adj] if _n==`i'+10	

			replace upper90 = _b[L`i'.spending_limit_predicted_adj] + 1.64*_se[L`i'.spending_limit_predicted_adj] if _n==`i'+10
			replace lower90 = _b[L`i'.spending_limit_predicted_adj] - 1.64*_se[L`i'.spending_limit_predicted_adj] if _n==`i'+10				
		
		}		
		
	
		keep if t!=.
		keep est upper* lower* t `v'
		
		twoway 	(rspike upper95 lower95 t,   lwidth(vthin)   	lcolor(black) ) || ///
				(rspike upper90 lower90 t,  lwidth(medthick) 	lcolor(black) ) || ///
				(dot est t , ndots(1) msymbol(s) mfcolor(white) mcolor(black) ) ///
				 , yline(0, lcolor(black) lpattern(solid)) ///
				 tlabel(-2 (1) 2) ytitle("Effect of Spending Limits" "(£10,000) on `: var la `v''", size(large)) xtitle("Elections Relative to Treatment" , size(large))	///
				xlabel(, labsize(medlarge)) ylabel(, labsize(medlarge)) 	legend( off) 	saving( ./figures/pretreatment_`v'.gph, replace) //scale(1.1)
		
		
		graph export ./figures/`v'.pdf, replace				
	
		project , creates("figures/`v'.pdf")	
	
	
	
	}
		
		
		

	
	
	
	
